import { _decorator, Component, Node, Button } from 'cc';
import { GameManager } from './GameManager';
const { ccclass, property } = _decorator;

@ccclass('GameOverUI')
export class GameOverUI extends Component {
    @property(Button)
    reviveButton: Button = null;

    @property(Node)
    gameManager: Node = null; // 绑定 GameManager 节点

    start() {
        this.reviveButton.node.on(Button.EventType.CLICK, this.onRevive, this);
    }

    onRevive() {
        // 通知 GameManager 复活
        const gm = this.gameManager.getComponent(GameManager);
        gm.revive();
        
        this.node.active = false; // 隐藏 GameOverUI
    }
}
